const Koa=require('koa');
const session=require('koa-session-minimal');
const redisStore=require('koa-redis');
const app=new Koa();


app.use(session({
    store:redisStore()
}));

app.use(async (ctx,next)=>{
    console.log(ctx.session);
    let count=(ctx.session.count||0)+1;
    ctx.session={
        user_id:Math.random().toString(36).substr(2),
        count
    };
    ctx.body=ctx.session;
});

app.listen(4000,()=>{
    console.log('StaticServer port:4000----'+new Date().toLocaleTimeString());
});